#ifndef __EKOS_KERNEL_PMEM_H__
#define __EKOS_KERNEL_PMEM_H__

/* Initialize the Physical Memory Sub-system */
/* The routine read the initial memory mapping stored by bootloader,
 * then do initial allocation works, then the buddy system */
int pmem_init(void);

/* For the naive mapping strategy */
#define PADDR(kva) ((physaddr_t)(kva) - KBASE)
#define KADDR(pa)  (void *)((pa) + KBASE)

/* the physical page allocator interface */
/* may implement the buddy system */
int  pmem_page_alloc(int num, physaddr_t *addr, int dma, int status);
void pmem_page_free(physaddr_t addr);
void pmem_page_add_ref(physaddr_t addr, int delta);
void pmem_page_inc_ref(physaddr_t addr);
void pmem_page_dec_ref(physaddr_t addr);
int  pmem_page_status(physaddr_t);
int  pmem_page_fsm(physaddr_t addr, int *tf_vec, int size);

#define PPAGE_MANAGED      0
#define PPAGE_CORE         1

// UNUSED
#define PPAGE_FSM_COUNT 7

#endif
